New Module

  • Step 1:

    1. Create custom module

    1. Enable developer mode

    2. add custom-addons path in odoo.conf

    
                    addons_path = e:\odoo\16\server\odoo\addons, e:\odoo\16\server\addons
                    

    3. new module

    windows

    Navigate to python.exe

    
                     //navigate 
                     cd  E:\odoo\python\python.exe
                     
                     //create new module
                     E:\odoo\server\odoo-bin scaffold school E:\odoo\server\addons
    
                      //restart service
                      go to searchbar -> type services -> restart odoo server
                    
    Linux

    Navigate to location of odoo-bin

    
                    ./odoo-bin scaffold school ../addons/
    
                    //restart server
                    sudo systemctl restart odoo14
                    

    2. Structure

    
                    controllers
                        - __init__.py
                        - controllers.py
                    demo
                        - demo.xml
                    models
                        - __init__.py
                        - models.py
                    security
                        - ir.model.access.csv
                    views
                        - templates.xml
                        - views.xml
                    
                    __init__.py   
                    __manifest__.py 
                    
    1 . all model should be added in models/__init__.py
    2. all xml should be added in __manifest__.py
    3. enable ir.model.access.csv in __manifest__.py 4. uncomment the code in models/models.py, security/ir.model.access.csv, view/views.xml
  • Step 2: Settings

    1. Enable Application Mode

    open E:\odoo\16\server\addons\school\__manifest__.py

    add 'application': True,

    2. Module icon image

    1.copy the image to E:\odoo\16\server\addons\school\static\description\icon.png

  • Step3 : Menu and view

    menu

    
                    
        <menuitem name="csms" id="csms.menu_root"/>
    
        <!-- menu categories -->
    
        <menuitem name="Activities" id="csms.menu_1" parent="csms.menu_root"/>
        <menuitem name="Masters" id="csms.menu_2" parent="csms.menu_root"/>
    
        <!-- actions -->
    
        <menuitem name="List" id="csms.menu_1_list" parent="csms.menu_1"
                action="csms.action_window"/>
    
    
        <menuitem name="Agent Master" id="menu_agent" parent="csms.menu_2"
                action="agent_action_window"/>
        <menuitem name="Country Master" id="menu_country" parent="csms.menu_2"
                action="country_action_window"/>
    
    

    Action window

    
    <record model="ir.actions.act_window" id="agent_action_window">
          <field name="name">Agent Master</field>
          <field name="res_model">csms.agent</field>
          <field name="view_mode">tree,form</field>
        </record>
    
        <record model="ir.actions.act_window" id="country_action_window">
          <field name="name">Country Master</field>
          <field name="res_model">csms.country</field>
          <field name="view_mode">tree,form</field>
        </record>